package com.vpclub.controller;

import com.vpclub.bean.Book;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;

/**
 * @author : leimingchao
 * @date Date : 2021年07月29日 20:34
 */
@Controller
public class HelloController {

    @RequestMapping(value = "/hello")
    public String hello() {
        System.out.println("目标方法运行了。hello");
        return "success";
    }

    @RequestMapping(value = "/hello2")
    public String hello2(String username, Integer age, int number, Date date,Model model) {
        System.out.println("目标方法运行了。hello2");
        System.out.println("姓名是：" + username + ",年龄是：" + age + ",数量是：" + number + ",日期是：" + date);
        System.out.println(model);
        return "success";
    }

    @RequestMapping(value = "/addBook", method = RequestMethod.POST)
    public String addBook(@RequestBody Book book, HttpServletRequest request, HttpServletResponse response,Model model) {
        System.out.println(book);
        System.out.println(model);
        return "success";
    }
}
